<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>

<div class="easyui-layout" fit="true">
  <div region="center" style="padding:1px;">
  <t:datagrid name="annealerReportList" title="工序汇报" actionUrl="annealerReport004Controller.do?datagrid"
              queryParams="{process:'${process}'}" idField="id" fit="true" queryMode="group" rowStyler="setMyColor">
   <t:dgCol title="编号" field="id" hidden="true" ></t:dgCol>
   <t:dgCol title="状态" field="fstate" dictionary="hbstate" style="setColor()" query="true" ></t:dgCol>
   <t:dgCol title="炉号" field="flh" ></t:dgCol>
   <t:dgCol title="卷号id" field="fhbid" hidden="true"></t:dgCol>
   <t:dgCol title="生产车间" field="fworkshop" dictionary="workshop" ></t:dgCol>
   <t:dgCol title="机组" field="fmatchinegroup" ></t:dgCol>
   <t:dgCol title="班组" field="fworkgroup" dictionary="team"></t:dgCol>
   <t:dgCol title="备注" field="fnote" ></t:dgCol>
  <t:dgCol title="制单"    field="createBy" hidden="false"></t:dgCol>
   <t:dgCol title="汇报人"    field="updateBy" ></t:dgCol>
   <t:dgCol title="投料日期"  field="createDate"  formatter="yyyy-MM-dd"  query="true" queryMode="group"></t:dgCol>
   
   
   <t:dgToolBar title="工序汇报" icon="icon-edit" url="annealerReport004Controller.do?addorupdate" funname="update_check" operationCode="processReport4"></t:dgToolBar>
   <t:dgToolBar title="反汇报" icon="icon-undo"     url="annealerReport004Controller.do?returnReport4" funname="returnReport4" operationCode="returnReport4"></t:dgToolBar>
   <t:dgToolBar title="卸炉" icon="icon-undo"     url="processReport004Controller.do?returnReport2" funname="returnReport2" operationCode="returnReport2"></t:dgToolBar>
   <t:dgToolBar title="温度记录" icon="icon-edit" url="annealerReport004Controller.do?addtemp" funname="addtemp"></t:dgToolBar>
   <t:dgToolBar title="查看" icon="icon-search" url="annealerReport004Controller.do?addorupdate" funname="detail"></t:dgToolBar>
  </t:datagrid>
  </div>
</div>
 
 
 <script>
 	function setMyColor(index,row){
 		var value=row.fstate;
 		if(value==0){
 			return "color:blue;";
 		}
 		if(value==1){
 			return "color:red;";
 		}
 		if(value==2){
 			return "color:green;";
 		}
 		if(value==3){
 			return "color:orange;";
 		}
 		return "";
 	
 	}
 	
 	
 	/**
	 * 更新事件打开窗口
	 * @param title 编辑框标题
	 * @param addurl//目标页面地址
	 * @param id//主键字段
	 */
	function addtemp(title,url, id,width,height) {
		
		var rowsData = $('#'+id).datagrid('getSelections');
		if (!rowsData || rowsData.length==0) {
			tip('请选择编辑项目');
			return;
		}
		if (rowsData.length>1) {
			tip('请选择一条记录再编辑');
			return;
		}
		var fstate=rowsData[0].fstate;
		if(fstate!="0" && fstate!="1"){
			url += '&load=detail';
		}
		url += '&id='+rowsData[0].id;
		createwindow(title,url,width,height);
	}




	function update_check(title,url, id,width,height) {
 	
 		var rowsData = $('#'+id).datagrid('getSelections');
		if (!rowsData || rowsData.length==0) {
			tip('请选择编辑项目');
			return;
		}
		if (rowsData.length>1) {
			tip('请选择一条记录再编辑');
			return;
		}
		
		var fstate=rowsData[0].fstate;
		if(fstate!="0" && fstate!="1"){
			tip('该记录已汇报');
			return;
		}
		update(title,url, id,width,height);
	}
	
		$(document).ready(function(){
		$("input[name='createDate_begin']").attr("class","easyui-datebox");
		$("input[name='createDate_end']").attr("class","easyui-datebox");
	});
 </script>